package com.lsl.Interface;

/**
 * @author lishuailong
 * @create 2020-06-11 10:03
 */
public class test2 {
    public static void main(String[] args) {
        AgencyFly agencyFly = new AgencyFly(new PlaneFly());
        agencyFly.takeOff();
    }
}

//声明一个借口
interface Fly{
    void takeOff();
}
//被代理类
class PlaneFly implements Fly{

    @Override
    public void takeOff() {
        System.out.println("飞机起飞！");
    }
}
//代理类
class AgencyFly implements Fly{
    private PlaneFly planeFly;

    public AgencyFly(PlaneFly planeFly) {
        this.planeFly = planeFly;
    }


    public void jiancha(){
        System.out.println("起飞检查！");
    }

    @Override
    public void takeOff() {
        jiancha();
        planeFly.takeOff();
    }
}
